<%@ Page Language="C#" MasterPageFile="~/MasterPageMcSigAdmin.master" AutoEventWireup="true"
    CodeFile="SigPlanPrograma.aspx.cs" Inherits="SigPlanPrograma" Title="Untitled Page" %>
<%@ Register Assembly="FUA" Namespace="Subgurim.Controles" TagPrefix="cc2" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView.Export" tagprefix="dxwgv" %>    
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="Anthem" Namespace="Anthem" TagPrefix="anthem" %>
<%@ Register Assembly="UsrControls" Namespace="UsrControls" TagPrefix="cc1" %>
<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script language="javascript" type="text/javascript">
    function OnGridSelectionChanged() {
    var counter = document.getElementById("selCount");
    if(counter != null) 
    setInnerText(counter, ctl00_ContentPlaceHolder1_gridEntidades.GetSelectedRowCount().toString());
    
    ctl00_ContentPlaceHolder1_gridEntidades.GetSelectedFieldValues('PRG_NOMBRE', OnGridSelectionComplete);
}
function OnGridSelectionComplete(values) {
    selList.BeginUpdate();
    selList.ClearItems();
    for(var i = 0; i < values.length; i ++) {
        selList.AddItem(values[i]);
    }
    selList.EndUpdate();
}
function setInnerText(element, text) { 
    if(typeof element.textContent != 'undefined') { 
        element.textContent = text; 
    } 
    else if (typeof element.innerText != 'undefined') { 
        element.innerText = text; 
    } 
    else if (typeof element.removeChild != 'undefined') { 
        while (element.hasChildNodes()) { 
            element.removeChild(element.lastChild); 
        } 
        element.appendChild(document.createTextNode(text)); 
    } 
}

function confirmEdit()
{
var counter = ctl00_ContentPlaceHolder1_gridEntidades.GetSelectedRowCount();

if (counter > 1)
    {
    counter = 0;
        alert("Debe seleccionar un solo registro");
        return(false);
    }
    else if (counter == 1)
    {
    counter = 0;
        return(true);
    }
    else if (counter == 0)
    {
    counter = 0;
    alert("Debe seleccionar al  menos un registro");
        return(false);
    }
}
function delete_PreCallBack(button) 
{
var counter = ctl00_ContentPlaceHolder1_gridEntidades.GetSelectedRowCount();

if (counter > 0)
    {
        return confirm ('Esta seguro de eliminar los registros seleccionados?')
    }
  alert("Debe seleccionar por lo menos un registro");
    return(false);
  
}

function confirmDelete () 
{ 
		var frm;
		
		if (arguments.length > 0)
		{
			frm = arguments[0];
		}
		else
		{
			frm =document.forms[0];
		}



    // loop through all elements
    for (i=0; i<frm.length; i++) 
    {
        // Look for our checkboxes only
        if (frm.elements[i].name.indexOf("chkId") !=-1) 
        {
            // If any are checked then confirm alert, otherwise nothing happens
            if(frm.elements[i].checked) 
            {
                return confirm ('Esta seguro de eliminar los registros seleccionados?')
            }
        }
    }
    alert("Debe seleccionar por lo menos un registro");
    return(false);
}
    </script>
  
  <h1 class="planes">Planes y Programas</h1>
    
                <anthem:Label ID="lblMensaje" runat="server" AutoUpdateAfterCallBack="True" UpdateAfterCallBack="True"></anthem:Label>&nbsp;
                <anthem:ValidationSummary ID="ValidationSummary1" runat="server" AutoUpdateAfterCallBack="True" />
            
                <div class="toolbar">
                <asp:ImageButton ID="btnRegresar" runat="server" CssClass="regresar" ImageUrl="~/Imagenes/bt-regresar.gif"
                    OnClick="btnRegresar_Click" CausesValidation="False" />
                <cc1:WccAcciones ID="WccAcciones1" runat="server" OnAdd_OnClick="WccAcciones1_Add_OnClick"
                    ArchiveVisible="False" AuditVisible="False" DeclineVisible="False" PublishVisible="False"
                    ValidateVisible="False" OnUpdate_OnClick="WccAcciones1_Update_OnClick" OnDelete_OnClick="WccAcciones1_Delete_OnClick" AddAutoUpdateAfterCallBack="True" DeleteAutoUpdateAfterCallBack="True" UpdateAutoUpdateAfterCallBack="True" OnAudit_OnClick="WccAcciones1_Audit_OnClick" />
            </div><table class="tabs">
                    <tr>
                        <td class="tab-activo" style="height: 20px">
                            <anthem:LinkButton ID="lnkAgente" runat="server" EnableCallBack="False" CausesValidation="False"
                                Enabled="false">Plan Programa</anthem:LinkButton></td>
                        <td class="tab-inactivo" Visible="true" runat="server" id="td2" style="height: 20px">
                            <anthem:LinkButton ID="lnkEjecucion" runat="server" EnableCallBack="False"
                                CausesValidation="False" Enabled="true" OnClick="lnkEjecucion_Click">Ejecucion</anthem:LinkButton></td>
                        <td class="tab-inactivo" style="width: 100px; height: 20px;" align="center" Visible="true" runat="server" id="td3">
                            <anthem:LinkButton ID="LnkFormacionAcademica" runat="server" EnableCallBack="False"
                                CausesValidation="False" Enabled="true" OnClick="LnkFormacionAcademica_Click">Cofinanciacion</anthem:LinkButton></td>
                        <td class="tab-inactivo" Visible="false" runat="server" id="td4" style="height: 20px">
                            <anthem:LinkButton ID="lnkPublicacionesRelevantes" runat="server" EnableCallBack="False"
                                CausesValidation="False" Enabled="true">Otros</anthem:LinkButton></td>
                    </tr>
                </table>
                <cc1:PopupPanelConsultarAuditoria ID="popupPanelConsultarAuditoria" runat="server">
                </cc1:PopupPanelConsultarAuditoria>
            
            
            <table class="forma">
        <tr id="as" runat="server" visible="false">
            <td class="campo" style="width: 20%">
                Identificador</td>
            <td>
                <cc1:TextBoxBase ID="txtIdentificador" runat="server" IsNumeric="True" Width="200px"></cc1:TextBoxBase></td>
        </tr>
        <tr>
            <td style="width: 20%" class="campo-obligatorio">
                Programa</td>
            <td>
                <cc1:DropDownBase ID="ddlGrupo" runat="server" AutoCallBack="True" OnSelectedIndexChanged="ddlGrupo_SelectedIndexChanged">
                </cc1:DropDownBase><anthem:RequiredFieldValidator ID="req" runat="server" AutoUpdateAfterCallBack="True"
                    ControlToValidate="ddlGrupo" Display="Dynamic" ErrorMessage="Debe ingresar el campo Grupo">*</anthem:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td style="width: 20%; height: 24px;" class="campo-obligatorio">
                Proyecto</td>
            <td style="height: 24px">
                <cc1:DropDownBase ID="ddlPrograma" runat="server" AutoUpdateAfterCallBack="True">
                </cc1:DropDownBase><anthem:RequiredFieldValidator ID="reqddlPrograma" runat="server"
                    AutoUpdateAfterCallBack="True" ControlToValidate="ddlPrograma" Display="Dynamic"
                    ErrorMessage="Debe ingresar el campo Programa">*</anthem:RequiredFieldValidator>&nbsp;
            </td>
        </tr>
        <tr>
            <td class="campo">
                Cantidad</td>
            <td>
                <cc1:TextBoxBase ID="txtCantidad" runat="server" IsNumeric="True" Width="200px"></cc1:TextBoxBase></td>
        </tr>
        <tr>
            <td class="campo">
                Descripcion</td>
            <td>
                <anthem:TextBox ID="txtDescripcion" runat="server" Height="55px" TextMode="MultiLine"
                    Width="432px"></anthem:TextBox></td>
        </tr>
        <tr>
            <td class="campo-obligatorio">
                Ano</td>
            <td>
                <cc1:DropDownBase ID="ddlanos" runat="server">
                    <asp:ListItem Selected="True">
                    </asp:ListItem>
                    <asp:ListItem>1998</asp:ListItem>
                    <asp:ListItem>1999</asp:ListItem>
                    <asp:ListItem>2000</asp:ListItem>
                    <asp:ListItem>2001</asp:ListItem>
                    <asp:ListItem>2002</asp:ListItem>
                    <asp:ListItem>2003</asp:ListItem>
                    <asp:ListItem>2004</asp:ListItem>
                    <asp:ListItem>2005</asp:ListItem>
                    <asp:ListItem>2006</asp:ListItem>
                    <asp:ListItem>2007</asp:ListItem>
                    <asp:ListItem>2008</asp:ListItem>
                    <asp:ListItem>2009</asp:ListItem>
                    <asp:ListItem>2010</asp:ListItem>
                    <asp:ListItem>2011</asp:ListItem>
                    <asp:ListItem>2012</asp:ListItem>
                    <asp:ListItem>2013</asp:ListItem>
                </cc1:DropDownBase></td>
        </tr>
        <tr>
            <td class="campo">
                Observaciones</td>
            <td>
                <anthem:TextBox ID="txtObsevaciones" runat="server" Height="57px" TextMode="MultiLine"
                    Width="429px"></anthem:TextBox></td>
        </tr>
        <tr>
            <td class="campo">
                Valor</td>
            <td>
                <cc1:TextBoxBase ID="txtValor" runat="server" IsDecimal="True" Width="200px"></cc1:TextBoxBase></td>
        </tr>
        <tr>
            <td class="campo">
                Poblacion Beneficiada</td>
            <td>
                <cc1:TextBoxBase ID="txtPoblacionBeneficiada" runat="server" IsNumeric="True" Width="200px"
                    IsDecimal="False"></cc1:TextBoxBase></td>
        </tr>
        <tr>
            <td style="height: 26px" class="campo-obligatorio">
                Departamento</td>
            <td style="height: 26px">
                <cc1:DropDownBase ID="ddldepartamentosAnthem" runat="server" OnSelectedIndexChanged="ddldepartamentosAnthem_SelectedIndexChanged"
                    AutoCallBack="True" AutoUpdateAfterCallBack="True" Width="200px">
                </cc1:DropDownBase>
                <anthem:RequiredFieldValidator ID="reqddldepartamentosAnthem" runat="server" AutoUpdateAfterCallBack="True"
                    ControlToValidate="ddldepartamentosAnthem" Display="Dynamic" ErrorMessage="Debe ingresar el campo Departamento">*</anthem:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td style="height: 24px" class="campo-obligatorio">
                Municipio</td>
            <td style="height: 24px">
                <cc1:DropDownBase ID="ddlMunicipiosAnthem" runat="server" Width="200px">
                </cc1:DropDownBase>
                <anthem:RequiredFieldValidator ID="reqddlMunicipiosAnthem" runat="server" AutoUpdateAfterCallBack="True"
                    ControlToValidate="ddlMunicipiosAnthem" Display="Dynamic" ErrorMessage="Debe ingresar el campo Municipio">*</anthem:RequiredFieldValidator></td>
        </tr>
        <tr>
            <td style="height: 24px" class="campo">
                Resguardo</td>
            <td style="height: 24px">
                <cc1:DropDownBase ID="ddlResguardos" runat="server" AutoCallBack="True" Width="200px">
                </cc1:DropDownBase></td>
        </tr>
        <tr>
            <td class="campo" style="height: 24px">
                Fecha Avance</td>
            <td style="height: 24px">
                <ew:CalendarPopup ID="calFechaAvance" runat="server">
                </ew:CalendarPopup>
                
            </td>
        </tr>
        <tr>
            <td colspan="2" class="encabezado">
                ENTIDADES</td>
        </tr>
        <tr>
            <td colspan="2" >
                <table width="100%" class="content-box1">
                    <tr>
                        <td style="width: 20%" class="subtitulo">
                            Entidades Disponibles</td>
                        <td style="width: 18px">
                        </td>
                        <td class="subtitulo">
                            Entidades Asignadas</td>
                    </tr>
                    <tr>
                        <td>
                            <anthem:ListBox ID="ListBoxEntidadesDisponibles" SelectionMode="Multiple" runat="server" Height="216px" Width="297px" AutoUpdateAfterCallBack="True">
                            </anthem:ListBox></td>
                        <td style="width: 18px" style="vertical-align:middle">
                            <anthem:ImageButton ID="btnAdd" runat="server" ImageUrl="images/bt-ff1.gif" OnClick="btnAdd_Click" />
                            <anthem:ImageButton ID="btnAddAll" runat="server" ImageUrl="images/bt-adelante.gif" OnClick="btnAddAll_Click" />
                            <anthem:ImageButton ID="btnRemoveAll" runat="server" ImageUrl="images/bt-rev.gif" OnClick="btnRemoveAll_Click" />
                            <anthem:ImageButton ID="btnRemove" runat="server" ImageUrl="images/bt-rev1.gif" OnClick="btnRemove_Click" /></td>
                        <td>
                            <anthem:ListBox ID="ListBoxEntidadesAsignadas" SelectionMode="Multiple" runat="server" Height="216px" Width="349px" AutoUpdateAfterCallBack="True">
                            </anthem:ListBox></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="encabezado">
                IMAGENES</td>
        </tr>
        <tr>
            <td colspan="2" valign="top">
                <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
                </asp:ScriptManager>
                <dxwgv:ASPxGridView ID="gridImagenes" runat="server" CssFilePath="~/App_Themes/Plastic Blue/{0}/styles.css"
                    CssPostfix="Soft_Orange"  AutoGenerateColumns="False"
                    DataSourceID="SqlDataSource1" KeyFieldName="SIP_ID" Width="100%" OnRowDeleting="gridImagenes_RowDeleting">
                    <Images ImageFolder="~/App_Themes/Plastic Blue/{0}/">
                        <CollapsedButton Height="14px" Url="~/App_Themes/Plastic Blue/GridView/gvCollapsedButton.png"
                            Width="13px" />
                        <ExpandedButton Height="13px" Url="~/App_Themes/Plastic Blue/GridView/gvExpandedButton.png"
                            Width="13px" />
                        <DetailCollapsedButton Height="14px" Url="~/App_Themes/Plastic Blue/GridView/gvCollapsedButton.png"
                            Width="13px" />
                        <DetailExpandedButton Height="13px" Url="~/App_Themes/Plastic Blue/GridView/gvExpandedButton.png"
                            Width="13px" />
                        <HeaderFilter Height="19px" Url="~/App_Themes/Plastic Blue/GridView/gvHeaderFilter.png"
                            Width="19px" />
                        <HeaderActiveFilter Height="19px" Url="~/App_Themes/Plastic Blue/GridView/gvHeaderFilterActive.png"
                            Width="19px" />
                        <HeaderSortDown Height="3px" Url="~/App_Themes/Plastic Blue/GridView/gvHeaderSortDown.png"
                            Width="6px" />
                        <HeaderSortUp Height="3px" Url="~/App_Themes/Plastic Blue/GridView/gvHeaderSortUp.png"
                            Width="6px" />
                        <PopupEditFormWindowClose Height="18px" Width="18px" />
                    </Images>
                    <Styles CssFilePath="~/App_Themes/Plastic Blue/{0}/styles.css" CssPostfix="Soft_Orange">
                        <Header ImageSpacing="5px" SortingImageSpacing="5px">
                        </Header>
                        <LoadingPanel ImageSpacing="10px">
                        </LoadingPanel>
                    </Styles>
                    <Columns>
                        <dxwgv:GridViewCommandColumn VisibleIndex="0">
                            <EditButton Visible="True">
                            </EditButton>
                            <NewButton Visible="True">
                            </NewButton>
                            <DeleteButton Visible="True">
                            </DeleteButton>
                        </dxwgv:GridViewCommandColumn>
                        <dxwgv:GridViewDataTextColumn FieldName="SIP_ID" ReadOnly="True" Visible="False"
                            VisibleIndex="1">
                            <EditFormSettings Visible="False" />
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn FieldName="SPZ_ID" VisibleIndex="1" Visible="False">
                            <EditItemTemplate>
                                <dxe:ASPxTextBox ID="txtspz" runat="server" Width="170px" Value='<%# IdentificadorPszId%>' />
                            </EditItemTemplate>
                            <PropertiesTextEdit EnableClientSideAPI="True">
                            </PropertiesTextEdit>
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn Caption="Nombre" FieldName="SIP_NOMBRE" VisibleIndex="2">
                            <EditItemTemplate>
                                <dxe:ASPxTextBox ID="txtNombre" runat="server" Width="170px" Value='<%# Bind("SIP_NOMBRE") %>' />
                            </EditItemTemplate>
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn Caption="Descripcion" FieldName="SIP_DESCRIPCION" VisibleIndex="3">
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataTextColumn VisibleIndex="4" Caption="Upload">
                            <EditItemTemplate>
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
                                    <triggers>
                                            <asp:PostBackTrigger ControlID="UploadBtn" />
                                    </triggers>
                                    <contenttemplate>
                                               <table>
                                    <tr>
                                        <td colspan="2">
                                            <asp:FileUpload ID="FileUpload1" runat="server" Width="270px" /></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            File Uploaded:&nbsp;<asp:Label ID="Label1" runat="server" BackColor="#FFFF80"></asp:Label>
                                        </td>
                                        <td align="right">
                                            <asp:Button ID="UploadBtn" runat="server" Text="Upload" OnClick="UploadBtn_Click" />
                                        </td>
                                    </tr>
                                </table>
                                         </contenttemplate>
                                </asp:UpdatePanel>
                            </EditItemTemplate>
                        </dxwgv:GridViewDataTextColumn>
                    </Columns>
                    <Templates>
                        <PreviewRow>
                            <table style="border: none">
                                <tbody>
                                    <tr>
                                        <td style="width: 20%; border: none; color: Black">
                                            <img alt="" width="100px" height="60px" src='Archivos/<%#Eval("SIP_NOMBRE")%>' />
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </PreviewRow>
                    </Templates>
                    <SettingsPager>
                        <AllButton>
                            <Image Height="19px" Width="28px" />
                        </AllButton>
                        <FirstPageButton>
                            <Image Height="19px" Width="23px" />
                        </FirstPageButton>
                        <LastPageButton>
                            <Image Height="19px" Width="23px" />
                        </LastPageButton>
                        <NextPageButton>
                            <Image Height="19px" Width="19px" />
                        </NextPageButton>
                        <PrevPageButton>
                            <Image Height="19px" Width="19px" />
                        </PrevPageButton>
                    </SettingsPager>
                    <Settings ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" ShowPreview="True" />
                    <Paddings Padding="1px" />
                    <SettingsLoadingPanel Text="" />
                    <ImagesEditors>
                        <CalendarPrevYear Height="19px" Url="~/App_Themes/Plastic Blue/Editors/edtCalendarPrevYear.png"
                            Width="23px" />
                        <CalendarPrevMonth Height="19px" Url="~/App_Themes/Plastic Blue/Editors/edtCalendarPrevMonth.png"
                            Width="19px" />
                        <CalendarNextMonth Height="19px" Url="~/App_Themes/Plastic Blue/Editors/edtCalendarNextMonth.png"
                            Width="19px" />
                        <CalendarNextYear Height="19px" Url="~/App_Themes/Plastic Blue/Editors/edtCalendarNextYear.png"
                            Width="23px" />
                    </ImagesEditors>
                </dxwgv:ASPxGridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
                    DeleteCommand="DELETE FROM [SIG_IMAGENES_PROGRAMAS] WHERE [SIP_ID] = @SIP_ID"
                    InsertCommand="INSERT INTO [SIG_IMAGENES_PROGRAMAS] ([SPZ_ID], [SIP_NOMBRE], [SIP_DESCRIPCION]) VALUES (@SPZ_ID, @SIP_NOMBRE, @SIP_DESCRIPCION)"
                    SelectCommand="SELECT [SIP_ID], [SPZ_ID], [SIP_NOMBRE], [SIP_DESCRIPCION] FROM [SIG_IMAGENES_PROGRAMAS] WHERE ([SPZ_ID] = @SPZ_ID)"
                    UpdateCommand="UPDATE [SIG_IMAGENES_PROGRAMAS] SET [SPZ_ID] = @SPZ_ID, [SIP_NOMBRE] = @SIP_NOMBRE, [SIP_DESCRIPCION] = @SIP_DESCRIPCION WHERE [SIP_ID] = @SIP_ID">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtIdentificador" Name="SPZ_ID" PropertyName="Text"
                            Type="Decimal" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="SIP_ID" Type="Decimal" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="SPZ_ID" Type="Decimal" />
                        <asp:Parameter Name="SIP_NOMBRE" Type="String" />
                        <asp:Parameter Name="SIP_DESCRIPCION" Type="String" />
                        <asp:Parameter Name="SIP_ID" Type="Decimal" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="txtIdentificador" Name="SPZ_ID" PropertyName="Text"
                            Type="Decimal" />
                        <asp:Parameter Name="SIP_NOMBRE" Type="String" />
                        <asp:Parameter Name="SIP_DESCRIPCION" Type="String" />
                    </InsertParameters>
                </asp:SqlDataSource>
                &nbsp;
            </td>
        </tr>
    </table>
   
 
</asp:Content>
